package com.v3admin.common.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.function.Consumer;

/**
 * 扩展{@link com.baomidou.mybatisplus.extension.service.impl.ServiceImpl}
 *
 * @author Junpeng.Li
 * @date 2023-12-13 17:38
 */
public class IServiceImpl<M extends BaseMapper<T>, T> extends ServiceImpl<M, T> {

    protected QueryWrapper<T> queryWrapper() {
        return new QueryWrapper<>();
    }

    protected QueryWrapper<T> queryWrapper(Consumer<QueryWrapper<T>> consumer) {
        QueryWrapper<T> wrapper = queryWrapper();
        consumer.accept(wrapper);
        return wrapper;
    }

    protected UpdateWrapper<T> updateWrapper() {
        return new UpdateWrapper<>();
    }

    protected UpdateWrapper<T> updateWrapper(Consumer<UpdateWrapper<T>> consumer) {
        UpdateWrapper<T> wrapper = updateWrapper();
        consumer.accept(wrapper);
        return wrapper;
    }
}
